#include "System.h"
 FIXED_7_8 eli;
 
 
 DWORD e;
 
void main(void)
{
//Turn off the watch dog
KILL_THE_DOG;
InitClock();
InitGPIO();
InitButtonDetect();
InitTimerTPM1();
InitADC();
InitSCI1();
InitServos();
InitRPMMeasurement();
InitSystemVariables();
InitMessageDetect();
InitSensorCapture(); 
InitAutoNV();
EnableInterrupts;
 LED2_OFF;
  
for(;;)
{
  
   
  switch(SystemState)
   {
      default:
      case SYSTEM_STATE_INIT:
            EnterSystemState(SYSTEM_STATE_AUTO_NV);
      break;
      
      case SYSTEM_STATE_IDLE:
           ProcessIncomingBackdoorMessages();
           SendSmartCarStatusToHost();
      break;
      
      case SYSTEM_STATE_AUTO_NV:
          
          ProcessIncomingBackdoorMessages();
          
          SendSmartCarStatusToHost();
          
          AutoNV();
      
      break;
   }
}
 

}
